<template>
    <div class="authentication">
        <PersonalHeader :content="2"></PersonalHeader>
        <section class="authenticationmain">
            <section class="type">
                <h2 class="title">{{$t('userRz[0]')}}</h2>
                <ul class="contt">
                    <li class="list">
                        <a @click="primaryclick">
                            <img :src="require('_img/shenf/smrz-icon.png')" alt="">
                            <div class="two">
                                <h2>{{$t('userRz[1]')}}</h2>
                                <p v-if="userInfo.user.authentication ==  0">
                                    <span>{{$t('userRz[2]')}}</span>
                                </p>
                                <p v-else>
                                    <span>{{userInfo.auth.name}}</span>|
                                    <span>{{userInfo.auth.card_id}}</span>
                                </p>
                            </div>
                            <div class="three" v-if="userInfo.user.authentication ==  0">{{$t('userRz[3]')}}</div>
                            <div class="three" v-else>{{$t('userRz[4]')}}</div>
                        </a>
                    </li>
                    <li class="list">
                        <a @click="seniorclick">
                            <img :src="require('_img/shenf/gjrz-icon.png')" alt="">
                            <div class="two">
                                <h2>{{$t('userRz[5]')}}</h2>
                                <p>
                                    <span v-if="userInfo.user.authentication ==  2">{{$t('userRz[6]')}}</span>
                                    <span v-else-if="userInfo.user.authentication ==  3">{{$t('userRz[7]')}}</span>
                                    <span v-else-if="userInfo.user.authentication ==  4">{{$t('userRz[8]')}}</span>
                                    <span v-else>{{$t('userRz[9]')}}</span>
                                </p>
                                 <p>
                                    <span v-if="userInfo.user.authentication ==  4">{{userInfo.refuse_reason}}</span>
                                </p>
                            </div>
                            <div class="three" v-if="userInfo.user.authentication ==  0">{{$t('userRz[10]')}}</div>
                            <div class="three" v-else-if="userInfo.user.authentication ==  1">{{$t('userRz[11]')}}</div>
                            <div class="three" v-else-if="userInfo.user.authentication ==  2">{{$t('userRz[12]')}}</div>
                            <div class="three" v-else-if="userInfo.user.authentication ==  3">{{$t('userRz[13]')}}</div>
                            <div class="three" v-else>{{$t('userRz[14]')}}</div>
                        </a>
                    </li>
                </ul>
            </section>
        </section>
    </div>
</template>

<script>
import PersonalHeader from "_dom/personalheader"
import { mapActions } from "vuex"
export default {
    name: 'authentication',
        data () {
            return {
                userInfo:{
                  "user": {
                      "account": "", //用户账户
                      "phone": "", //用户手机
                      "email": "", //用户邮箱
                      "nickname": '',  //昵称
                      "avatar": "", //头像
                      "authentication": 0 // 认证状态0未认证1初级认证2高级认证待审核3高级认证通过4高级认证拒绝
                  },
                  "auth": {
                      "name": "", //姓名
                      "status": 0, //认证状态 0未认证 1初级认证 2高级认证待审核 3高级认证通过 4高级认证拒绝
                      "card_id": "", //身份证号
                      "refuse_reason": null //拒绝原因
                  }
                },
            }
        },
        methods: {
            ...mapActions([
                'getUserInfo'
            ]),
            getdata(){//
                this.getUserInfo().then(res => {
                    this.userInfo = res;
                }).catch(err => {
                    
                });
            },
            primaryclick(){
                let data = this.userInfo.user.authentication;
                switch (data) {
                    case 0:
                        this.$router.push({ path:"/authenticationprimary" });
                        break;
                    default:
                        this.$message.error(this.$t('userRz[15]'));
                        break;
                }
            },
            seniorclick(){
                let data = this.userInfo.user.authentication;
                switch (data) {
                    case 0:
                        this.$router.push({ path:"/authenticationprimary" });
                        break;
                    case 1:
                        this.$router.push({ path:"/authenticationsenior" });
                        break;
                    case 2:
                        this.$message.error(this.$t('userRz[16]'));
                        break;
                    case 3:
                        this.$message.error(this.$t('userRz[17]'));
                        break;
                    case 4:
                        this.$router.push({ path:"/authenticationsenior" });
                        break;
                    default:
                        this.$message.error(this.$t('userRz[17]'));
                        // this.$router.push({ path:"/authenticationsenior" });
                        break;
                };
            }

        },
        created(){
            this.getdata()
        },
        components: {
            PersonalHeader
        },
    }
</script>

